package com.neusoft.training.podcast.service.impl;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.training.podcast.entity.Comment;
import com.neusoft.training.podcast.mapper.CommentMapper;
import com.neusoft.training.podcast.service.CommentService;

@Service
public class CommentServiceImpl implements CommentService{

	@Autowired
	private CommentMapper commentMapper;
	
	@Override
	public void cleanComemnt(Integer commentID) {
		commentMapper.cleanComemnt(commentID);
	}

	@Override
	public void deleteComment(Integer commentID) {
		commentMapper.deleteComment(commentID);
	}

	@Override
	public List<Comment> findAll() {
		return commentMapper.findAll();
	}

	@Override
	public List<Comment> findCommentByContext(String context) {
		return commentMapper.findCommentByContext(context);
	}

	@Override
	public Comment findByID(Integer commentID) {
		return commentMapper.findByID(commentID);
	}

	/*
	 * 2018.3.18
	 * @author Cindy*/
	@Override
	public void insert(Integer commentUserID,
			String commentVideoID,
			String context,
			Timestamp commentTime,
			Integer addCommentID,
			Integer commentIsDel){
		commentMapper.insert(commentUserID,commentVideoID,context,commentTime,addCommentID,commentIsDel);
	}
	
	@Override
	public List<Comment> findCommendByVideoID(String commentVideoID){
		return commentMapper.findCommentByVideoID(commentVideoID);
	}
	
	@Override
	public List<Comment> findSecondaryComment(String commentVideoID,Integer commentID){
		return commentMapper.findSecondaryComment(commentVideoID, commentID);
	}
	// end
	
	@Override
	public List<Comment> findPersonVideoComment(Integer userID) {
		
		return commentMapper.findVideoComment(userID);
	}

	@Override
	public ArrayList<Integer> findCommentCount(ArrayList<String> videoID) {
		ArrayList<Integer> count=new ArrayList<Integer>();
		for(int i=0;i<videoID.size();i++)
		{
			count.add(commentMapper.findCommentCount(videoID.get(i)));
		}// TODO Auto-generated method stub
		return count;
	}

	@Override
	public List<Comment> findSelfComment(Integer userID) {
		// TODO Auto-generated method stub
		return commentMapper.findSelfComment(userID);
	}

	@Override
	public List<Comment> findOtherComment(Integer userID) {
		// TODO Auto-generated method stub
		return commentMapper.findOtherComment(userID);
	}

}
